import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

/// 编辑
typedef Edit = Function(BuildContext context);

/// 删除
typedef Delete = Function(BuildContext context);

/// 地块操作dialog
void showLandOperateDialog(
    {required BuildContext context,
    required Edit edit,
    required Delete delete}) {
  showDialog(
    context: context,
    builder: (context) {
      return LandOperateDialog(
        edit: edit,
        delete: delete,
      );
    },
  );
}

class LandOperateDialog extends StatelessWidget {
  Edit edit;
  Delete delete;

  LandOperateDialog({super.key, required this.edit, required this.delete});

  @override
  Widget build(BuildContext context) {
    return Center(
      child: Container(
        width: double.infinity,
        margin: EdgeInsets.symmetric(vertical: 10.w, horizontal: 32.w),
        padding: EdgeInsets.only(left: 15.w, right: 15.w, top: 15.w),
        decoration: BoxDecoration(
            color: Colors.white, borderRadius: BorderRadius.circular(10.w)),
        child: Column(
          mainAxisSize: MainAxisSize.min,
          children: [
            Text(
              '提示',
              style: TextStyle(color: const Color(0xFF333333), fontSize: 16.sp),
            ),
            SizedBox(
              height: 10.w,
            ),
            Container(
              padding: EdgeInsets.symmetric(vertical: 10.w),
              alignment: Alignment.center,
              child: Text(
                "请对地块进行所对应的操作",
                style:
                    TextStyle(color: const Color(0xFF333333), fontSize: 14.sp),
              ),
            ),
            SizedBox(
              height: 10.w,
            ),
            Container(
              height: 1.w,
              color: const Color(0xFFECECEC),
            ),
            Row(
              children: [
                Expanded(
                  child: GestureDetector(
                    onTap: () {
                      delete.call(context);
                    },
                    child: Container(
                      height: 50.w,
                      color: Colors.white,
                      alignment: Alignment.center,
                      child: Text(
                        "删除地块",
                        style: TextStyle(color: Colors.red, fontSize: 14.sp),
                      ),
                    ),
                  ),
                ),
                Container(
                  width: 1.w,
                  height: 50.w,
                  color: const Color(0xFFECECEC),
                ),
                Expanded(
                  child: GestureDetector(
                    onTap: () {
                      edit.call(context);
                    },
                    child: Container(
                      height: 50.w,
                      color: Colors.white,
                      alignment: Alignment.center,
                      child: Text(
                        "编辑地块",
                        style: TextStyle(
                            color: const Color(0xFF007AFF), fontSize: 14.sp),
                      ),
                    ),
                  ),
                ),
              ],
            )
          ],
        ),
      ),
    );
  }
}
